$('head meta')[0].setAttribute('content','upgrade-insecure-requests');
$('head meta')[0].setAttribute('http-equiv','Content-Security-Policy');
$('head meta')[1].setAttribute('content','upgrade-insecure-requests');
$('head meta')[1].setAttribute('http-equiv','Content-Security-Policy');

function login(uuid){
    var urse = $("#login-urse").val();
    var password = $("#login-password").val();
    if (!(/^\d{11}$/.test(urse)) || password == null){
        alert("账号或密码不符号标准");
        return;
    }
    $.ajax( {
        url:'/login/login',
        async: true,
        type:'post',
        data: {
            "uuid" : uuid,
            "phone" : urse,
            "password" : password
        },
        datatype : "json",
        success : function(datas) {
            alert(datas);
            window.close();
        },
        error : function() {
            alert("未获得到服务器数据");
        }
    });
}

var b = 0;
function  getCode(uuid){
    var urse = $("#verify-phone").val();
    if (!(/^\d{11}$/.test(urse))){
        alert("手机号格式错误");
        return;
    }
    if (b>0){
        alert("请等待"+b+"秒后再重试")
        return;
    }
    $.ajax( {
        url:'/login/getCode',
        async: true,
        type:'post',
        data: {
            "uuid" : uuid,
            "phone" : urse,
        },
        datatype : "json",
        success : function(datas) {
            alert(datas);
        },
        error : function() {
            alert("未获得到服务器数据");
        }
    });
    b = 60;
    var a = setInterval(function (){
        b--;
        if (b <= 0) clearInterval(a);
    },1000);
}

function login_phone(uuid){
    var phone = $("#verify-phone").val();
    var code = $("#verify-code").val();
    if (!(/^\d{11}$/.test(phone)) || code == null){
        alert("账号或密码不符号标准");
        return;
    }
    $.ajax( {
        url:'/login/login_phone',
        async: true,
        type:'post',
        data: {
            "uuid" : uuid,
            "phone" : phone,
            "code" : code
        },
        datatype : "json",
        success : function(datas) {
            alert(datas);
            window.close();
        },
        error : function() {
            alert("未获得到服务器数据");
        }
    });
}